/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
//作者:AKPower
//算法:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 5e4 + 10;
int n, Q;
int a[maxn];
int acopy[maxn];
int lis[maxn];
bool con[maxn]; //标记是否还有
struct query
{
    int h, id, ans;
    bool operator<(const query &oth) const
    {
        return h < oth.h;
    }
} q[maxn];
vector<int> g[maxn]; //不同高度记录位置
int ans[maxn];
int main()
{
    IOS;
    cin >> n >> Q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        acopy[i] = a[i];
        con[i] = true;
    }
    con[0] = false;
    con[n + 1] = false;
    for (int i = 1; i <= Q; i++)
    {
        cin >> q[i].h;
        q[i].id = i;
    }
    sort(acopy + 1, acopy + n + 1);
    int size = unique(acopy + 1, acopy + n + 1) - (acopy + 1);
    acopy[0] = 0;
    acopy[size + 1] = 0x3f3f3f3f;
    for (int i = 1; i <= n; i++)
    {
        int p = lower_bound(acopy + 1, acopy + size + 1, a[i]) - acopy;
        a[i] = p;
    }
    for (int i = 1; i <= Q; i++)
    {
        int p = lower_bound(acopy, acopy + size + 2, q[i].h) - acopy;
        if (q[i].h == acopy[p])
            q[i].h = p;
        else
            q[i].h = p - 1;
    }
    //离散化完了
    // for (int i = 1; i <= n; i++)
    //     cout << a[i] << endl;
    // for (int i = 1; i <= Q; i++)
    //     cout << q[i].h << endl;
    for (int i = 1; i <= n; i++)
    {
        g[i].clear();
    }
    for (int i = 1; i <= n; i++)
    {
        g[a[i]].push_back(i); //记录位置
    }
    int preh = 0;
    int delta = 0;
    int preans = 0;
    for (int k = 1; k <= Q; k++)
    {
        delta = 0;
        if (q[k].h == q[k - 1].h)
        {
            q[k].ans = q[k - 1].ans;
        }
        else
        {
            for (int i = preh; i <= q[k].h; i++)
            {
                for (int j = 0; j < g[i].size(); j++)
                {
                    if (g[i][j] == 1)
                    {
                        if (con[g[i][j] + 1] == false)
                            delta--;
                    }
                    else if (g[i][j] == n)
                    {
                        if (con[g[i][j] - 1] == false)
                            delta--;
                    }
                    else
                    {
                        if (con[g[i][j] - 1] == false && con[g[i][j] + 1] == false)
                        {
                            delta--;
                        }
                        else if (con[g[i][j] - 1] == true && con[g[i][j] + 1] == true)
                        {
                            delta++;
                        }
                    }
                    con[g[i][j]] = false;
                }
            }
            q[k].ans = preans + delta;
            preh = q[k].h;
            preans = q[k].ans;
        }
    }
    for (int i = 1; i <= Q; i++)
    {
        ans[q[i].id] = q[i].ans;
    }
    for (int i = 1; i <= Q; i++)
    {
        cout << ans[i] << endl;
    }
    getchar();
    getchar();
    return 0;
}
